package cn.icanci.ladybird.service.impl;

import cn.icanci.ladybird.pojo.entity.TicketElectronic;
import cn.icanci.ladybird.dao.TicketElectronicDao;
import cn.icanci.ladybird.service.TicketElectronicService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TicketElectronic)表服务实现类
 *
 * @author makejava
 * @since 2020-09-29 20:44:23
 */
@Service("ticketElectronicService")
public class TicketElectronicServiceImpl implements TicketElectronicService {
    @Resource
    private TicketElectronicDao ticketElectronicDao;

    /**
     * 通过ID查询单条数据
     *
     * @param ticketElectronicId 主键
     * @return 实例对象
     */
    @Override
    public TicketElectronic queryById(Long ticketElectronicId) {
        return this.ticketElectronicDao.queryById(ticketElectronicId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TicketElectronic> queryAllByLimit(int offset, int limit) {
        return this.ticketElectronicDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param ticketElectronic 实例对象
     * @return 实例对象
     */
    @Override
    public TicketElectronic insert(TicketElectronic ticketElectronic) {
        this.ticketElectronicDao.insert(ticketElectronic);
        return ticketElectronic;
    }

    /**
     * 修改数据
     *
     * @param ticketElectronic 实例对象
     * @return 实例对象
     */
    @Override
    public TicketElectronic update(TicketElectronic ticketElectronic) {
        this.ticketElectronicDao.update(ticketElectronic);
        return this.queryById(ticketElectronic.getTicketElectronicId());
    }

    /**
     * 通过主键删除数据
     *
     * @param ticketElectronicId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long ticketElectronicId) {
        return this.ticketElectronicDao.deleteById(ticketElectronicId) > 0;
    }
}